//#include "log.h"
#include "LoggerMng.h"

//void *f(void* args)
//{
//    (void)args;
//    for(int i = 0;i < 100; i++)
//    {
//            Log::get_instance()->write_log(1, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);
//            Log::get_instance()->write_log(2, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);
//            Log::get_instance()->write_log(3, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);

//            LOG_INFO("%d", 123456789);
//            LOG_ERROR("%d", 123456789);
//            LOG_DEBUG("%d", 123456789);
//            LOG_WARN("%d", 123456789);

//    }
//    return nullptr;
//}

int main()
{
//    LoggerMng::Instance().init(LOG_FILE_PATH);

//    LoggerMng::Instance().get()->init(LOG_FILE_PATH);
//    LoggerMng::getInstance()->init(LOG_FILE_PATH);

//    LoggerMng::getInstance()->init(LOG_FILE_PATH);

//    LoggerMng::Instance().init(LOG_FILE_PATH);

    LoggerMng::ptrInstance().get()->init(LOG_FILE_PATH);
    for ( int i=0; i< 10; i++ )
    {
        string str = string("AD") + std::to_string(i) ;
        _DEBUG("你好, 教练%s, 我是成员: %d", str.c_str(), i);
    }

    string str = "AD";
    _ERROR("ERROR");
    _INFO("str: %s", str.c_str());
    _WARN("num: %d - str: %s", 8, str.c_str());

#if 0
    Log::get_instance()->init("./mylog.log", 100, 2000000, 10);

    LOG_INFO("%d", 123456789);
    LOG_ERROR("%d", 123456789);
    LOG_DEBUG("%d", 123456789);
    LOG_WARN("%d", 123456789);

    LOG_INFO("%s", "AADFASDFASDFADFASDFASDF");
    LOG_INFO("%s", "案件覅及附加到是觉得覅欧锦啊手动阀合法的防护及附近发发货的加法和喀什地方就按时到货付款和飞机喀什的回复");
#endif

#if 0
    Log::get_instance()->init("./mylog.log", 100, 2000000, 10);
    //Log::get_instance()->init("./mylog.log", 100, 2000000, 0);//synchronization model

    sleep(1);
    int i = 0;
    Log::get_instance()->write_log(1, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);
    Log::get_instance()->write_log(2, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);
    Log::get_instance()->write_log(3, "d=%d,c=%c,s=%s,f=%f", i,'a',"log", 1.000);

    LOG_INFO("%d", 123456789);
    LOG_ERROR("%d", 123456789);
    LOG_DEBUG("%d", 123456789);
    LOG_WARN("%d", 123456789);

    pthread_t id;
    for(int i = 0; i < 1; i++)
    {
        pthread_create(&id, NULL, f, NULL);
        pthread_join(id,NULL);
    }

    //for(;;)
    {
        sleep(15);
        Log::get_instance()->flush();
    }
#endif

    return 0;
}
